package com.huizu.framework.web.service;

import cn.hutool.core.util.StrUtil;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 重写Cas入口
 * 自定义客户端第一次回调路径  http://localhost:9999/testLogin/casLogin?url=123123
 * 主要是为了进行url参数的回调获取
 *
 * @author ruoyi
 */
public class CasAuthenticationRedirect extends CasAuthenticationEntryPoint {

    @Override
    protected String createServiceUrl(final HttpServletRequest request, final HttpServletResponse response) {
        String serviceUrlBak = getServiceProperties().getService();
        String queryString = request.getQueryString();
        String serviceUrl = "";
        if (StrUtil.isNotBlank(queryString)) {
            serviceUrl += "?" + queryString;
        }
        getServiceProperties().setService(serviceUrlBak + serviceUrl);
        return super.createServiceUrl(request, response);
    }
}
